package cn.com.guage.dtm.jubian;

import java.util.Scanner;

public class MaxSquareMatrix {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.nextLine(); // 消耗换行符
        
        char[][] matrix = new char[n][];
        for (int i = 0; i < n; i++) {
            matrix[i] = scanner.nextLine().toCharArray();
        }
        
        int rows = matrix.length;
        if (rows == 0) {
            System.out.println(0);
            return;
        }
        int cols = matrix[0].length;
        
        int[][] dp = new int[rows][cols];
        int maxLen = 0;
        
        // 初始化第一行和第一列
        for (int i = 0; i < rows; i++) {
            dp[i][0] = matrix[i][0] == '1' ? 1 : 0;
            maxLen = Math.max(maxLen, dp[i][0]);
        }
        for (int j = 0; j < cols; j++) {
            dp[0][j] = matrix[0][j] == '1' ? 1 : 0;
            maxLen = Math.max(maxLen, dp[0][j]);
        }
        
        // 填充dp表
        for (int i = 1; i < rows; i++) {
            for (int j = 1; j < cols; j++) {
                if (matrix[i][j] == '1') {
                    dp[i][j] = Math.min(Math.min(dp[i-1][j], dp[i][j-1]), dp[i-1][j-1]) + 1;
                    maxLen = Math.max(maxLen, dp[i][j]);
                } else {
                    dp[i][j] = 0;
                }
            }
        }
        
        System.out.println(maxLen * maxLen);
    }
}
